<template>
  <div class="box">
    <dog
      v-for="(item, index) in arrImg"
      :key="index"
      :imgurl="item.dogImgUrl"
      :dogName="item.dogName"
      :index="index"
      @write="addFn"
    >
    </dog>
    <p>你喜欢的狗狗如下：{{ lovedog }}</p>
  </div>
</template>

<script>
import dog from '../components/sell dogs.vue'
export default {
  components: {
    dog,
  },
  data() {
    return {
      lovedog: [],
      arrImg: [
        {
          dogImgUrl:
            'http://nwzimg.wezhan.cn/contents/sitefiles2029/10146688/images/21129958.jpg',
          dogName: '博美',
        },
        {
          dogImgUrl:
            'http://nwzimg.wezhan.cn/contents/sitefiles2029/10146688/images/21129958.jpg',
          dogName: '泰迪',
        },
        {
          dogImgUrl:
            'http://nwzimg.wezhan.cn/contents/sitefiles2029/10146688/images/21129958.jpg',
          dogName: '金毛',
        },
        {
          dogImgUrl:
            'https://pic1.zhimg.com/80/v2-7ba4342e6fedb9c5f3726eb0888867da_1440w.jpg?source=1940ef5c',
          dogName: '哈士奇',
        },
        {
          dogImgUrl:
            'https://pic1.zhimg.com/80/v2-7ba4342e6fedb9c5f3726eb0888867da_1440w.jpg?source=1940ef5c',
          dogName: '阿拉斯加',
        },
        {
          dogImgUrl:
            'https://pic1.zhimg.com/80/v2-7ba4342e6fedb9c5f3726eb0888867da_1440w.jpg?source=1940ef5c',
          dogName: '萨摩耶',
        },
      ],
    }
  },
  methods: {
    addFn(index) {
      console.log(index);
      this.lovedog.push(this.arrImg[index].dogName)
    }
  }
}
</script>

<style>
.box {
  display: flex;
  flex-wrap: wrap;
  width: 1000px;
}
</style>
